package cn.edu.nju.software.cdiy.algorithm.performance;

import cn.edu.nju.software.cdiy.bean.Driver;
import cn.edu.nju.software.cdiy.util.Constant;


public class DriverEvaluator implements Evaluator<Driver>{

	@Override
	public double getPerformance(Driver t) {
		double score = 0;
		
		//缓存容量得分
		String cacheSize = t.getCacheSize().getValue();
		double cacheSizeScore = getCacheSizeBase(cacheSize)*Constant.DRI_STD_CACHESIZE;
		
		//接口类型得分
		String intfType = t.getIntfType().getName();
		double intfTypeScore = getIntfTypeBase(intfType)*Constant.DRI_STD_INTFTYPE;
		
		
		
		
		
		score = cacheSizeScore+intfTypeScore;
		return score;
	}

	private double getIntfTypeBase(String intfType) {
		/*
		 * 接口类型基础分
		 * IDE接口		60
		 * USB2.0		70	
		 * USB3.0		80
		 * SATA接口		90
		 * */
		if(intfType.equals("IDE接口"))
			return 60;
		else if(intfType.equals("USB2.0"))
			return 70;
		else if(intfType.equals("USB3.0"))
			return 80;
		else if(intfType.equals("SATA接口"))
			return 90;
		else return 95;
	}

	private double getCacheSizeBase(String cacheSize) {
		/*
		 * 缓存容量基础分
		 * 1MB以下		60
		 * 1MB			75
		 * 2MB			85
		 * */
		if(cacheSize.equals("1MB以下"))
			return 60;
		else if(cacheSize.equals("1MB"))
			return 75;
		else if(cacheSize.equals("2MB"))
			return 85;
		else return 90;
	}

}
